package com.wkg.springblogdemo.pojo.response;


import com.wkg.springblogdemo.constant.Constants;
import lombok.Data;

@Data
public class Result<T> {
    private int code;
    private String errMsg;
    private T data;

    public static <T> Result success(T data) {
        Result result = new Result();
        result.setCode(Constants.RESULT_SUCCESS);
        result.setErrMsg("登录成功/获取数据成功");
        result.setData(data);
        return result;
    }

    public static <T> Result fail(String errMsg) {
        Result result = new Result();
        result.setCode(Constants.RESULT_FAIL);
        result.setErrMsg(errMsg);
        return result;
    }

    public static <T> Result fail(String errMsg, T data) {
        Result result = new Result();
        result.setCode(Constants.RESULT_FAIL);
        result.setErrMsg(errMsg);
        result.setData(data);
        return result;
    }

}
